<?php
	include "common.php";
	error_reporting(0);
	session_start();
	if($_SESSION['logInCheck']!=1){
		header('Location: index.php?loginInfo=false');
	}	
	$userLink = $_SESSION['userLink'];

	$userFname = $_SESSION['userFname'];
	$userLname = $_SESSION['userLname'];
	$ID = $_SESSION['id'];
	$userName = $_SESSION['userFname'];
	$role = $_SESSION['role'];
	$supervisor = $_SESSION['supervisor'];
	$userSql = "SELECT * FROM user WHERE e_id = '$supervisor'";
	$userSqlQuery = mysql_query($userSql);
	$userSqlQueryResult = mysql_fetch_assoc($userSqlQuery);	
	$supervisorFname = $userSqlQueryResult['f_name'];
	$supervisorLname = $userSqlQueryResult['l_name'];
	$supervisorName = $supervisorFname." ".$supervisorLname;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="emp_index.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="show_report.css" />
<link rel="icon" type="image/ico" href="images/favicon.ico"></link> 
<link rel="shortcut icon" href="images/favicon.ico"></link>
<script src="curvycorners.src.js" type="text/javascript"></script>
<script src="login.js" type="text/javascript"></script>
<title><?php echo "Welcome to ".$userFname." ".$userLname; ?></title>
</head>

<body>
<div class="main_div_other">
	<p><img src="images/creato_logo.jpg" /></p>
    <p id="creatobd">www.creatobd.com</p>
    <p id="date"><script>document.write(new_month+" "+new_date+", "+old_date.getFullYear()+" || "+new_day);</script></p>
    <div class="other_page_icons">
    	<div class="new_notification">
        	<img src="images/arrow_up.JPG" /><?php if ($notification >0){?><p>You have<?php echo " ".$notification." ";?>new notification</p><?php }?>
        </div><!--end of new_notification-->
    	<ul>
        	<a href="employee.php"><li><div id="home"></div><p>home</p><p class="present_class"><img src="images/arrow_up.JPG" /></p></li></a>
            <a href="work_night.php"><li><div id="employee"></div><p>Work At Night</p><p class="present_class"><img src="images/arrow_up.JPG" /></p></li></a>
            <a href="emp_attendance.php"><li><div id="attendance"></div><p>attendance</p><p class="present_class"><img src="images/arrow_up.JPG" /></p></li></a>
            <a href="emp_leave.php"><li><div id="leave"></div><p>leave</p><p class="present_class"><img src="images/arrow_up.JPG" /></p></li></a>
            <a href="notification.php"><li><div id="notification"></div><p>notification</p><p class="present_class"><img src="images/arrow_up.JPG" /></p></li></a>
            <a href="emp_black_box.php"><li><div id="blackbox"></div><p>black box</p><p class="present_class"><img src="images/arrow_up.JPG" /></p></li></a>
            <a href="index.php"><li><div id="logout"></div><p>log out</p><p class="present_class"><img src="images/arrow_up.JPG" /></p></li></a>
        </ul>
    </div><!-- end of other_page_icons-->
    
</div><!-- end of main_div_other-->
<div class="othrpage_1">
    <p>Apply For: <a href="work_night.php?check=1">Work At Night</a> | <a href="work_night.php?check=2">Meeting</a> | 
	<a href="work_night.php?check=3">Medical Doc</a></p>
</div><!-- end of othrpage_1-->
<div class="human_portal">
  		<p>creato human resourse portal</p>
</div><!-- end of human_portal-->
<div class="page_content">
	<?php
		$checkSubmit = $_GET['check'];
		if ($checkSubmit == 1)
		{
	?>
			<form method="post" action="work_tonight.php">
			<table cellpadding="0" cellspacing="0" class="apply4leave_table">
				<tr valign="top">
					<td>Employee Id</td>
					<td><input type="text" value="<?php echo $userName;?>" name="e_id" /></td>
				</tr>
				<tr valign="top">
					<td>Place</td>
					<td><input type="text" name="place" /></td>
				</tr>
				<tr valign="top">
					<td>Client</td>
					<td><input type="text" name="client" /></td>
				</tr>
				<tr valign="top">
					<td>Supervisor</td>
					<td><input type="text" value= "<?php echo $supervisorName; ?>" name="supervisor"/></form></td>
				</tr>
				<tr valign="top">
					<td>Work From</td>
					<td><select name="day"/>
												<option value="Day">Day</option><option value="1">1</option><option value="2">2</option>
												<option value="3">3</option><option value="4">4</option><option value="5">5</option>
												<option value="7">6</option><option value="8">7</option><option value="9">8</option>
												<option value="9">9</option><option value="10">10</option><option value="11">11</option>
												<option value="12">12</option><option value="13">13</option><option value="14">14</option>
												<option value="15">15</option><option value="16">16</option><option value="17">17</option>
												<option value="18">18</option><option value="19">19</option><option value="20">20</option>
												<option value="21">21</option><option value="22">22</option><option value="23">23</option>
												<option value="24">24</option><option value="25">25</option><option value="26">26</option>
												<option value="27">27</option><option value="28">28</option><option value="29">29</option>
												<option value="30">30</option><option value="31">31</option>
											</select>
											<select name="month"> 
												<option value="month1">Month</option><option value="1">January</option>
												<option value="2">February</option><option value="3">March</option><option value="4">April</option>
												<option value="5">May</option><option value="6">June</option><option value="7">July</option>
												<option value="8">august</option><option value="9">September</option>
												<option value="10">October</option><option value="11">November</option>
												<option value="12">December</option>
											</select>
											<select name="year">
												<option value="year">Year</option><option value="2012">2012</option><option value="2013">2013</option>
												<option value="2014">2014</option><option value="2015">2015</option><option value="2016">2016</option>
												<option value="2017">2017</option><option value="2018">2018</option><option value="2019">2019</option>
												<option value="2020">2020</option>
											</select><br><br>
						</td>
				</tr>
				<tr valign="top">
					<td>Work To</td>
					<td><select name="day1"/>
												<option value="Day1">Day</option><option value="1">1</option><option value="2">2</option>
												<option value="3">3</option><option value="4">4</option><option value="5">5</option>
												<option value="7">6</option><option value="8">7</option><option value="9">8</option>
												<option value="9">9</option><option value="10">10</option><option value="11">11</option>
												<option value="12">12</option><option value="13">13</option><option value="14">14</option>
												<option value="15">15</option><option value="16">16</option><option value="17">17</option>
												<option value="18">18</option><option value="19">19</option><option value="20">20</option>
												<option value="21">21</option><option value="22">22</option><option value="23">23</option>
												<option value="24">24</option><option value="25">25</option><option value="26">26</option>
												<option value="27">27</option><option value="28">28</option><option value="29">29</option>
												<option value="30">30</option><option value="31">31</option>
											</select>
											<select name="month1"> 
												<option value="month1">Month</option><option value="1">January</option>
												<option value="2">February</option><option value="3">March</option><option value="4">April</option>
												<option value="5">May</option><option value="6">June</option><option value="7">July</option>
												<option value="8">august</option><option value="9">September</option>
												<option value="10">October</option><option value="11">November</option>
												<option value="12">December</option>
											</select>
											<select name="year1">
												<option value="year1">Year</option><option value="2012">2012</option><option value="2013">2013</option>
												<option value="2014">2014</option><option value="2015">2015</option><option value="2016">2016</option>
												<option value="2017">2017</option><option value="2018">2018</option><option value="2019">2019</option>
												<option value="2020">2020</option>
												</select><br><br>
								</td>
				</tr>

				<tr>
					<td>Reason</td>
					<td><textarea name="reason" cols="18" rows="5"></textarea></td>
				</tr>
				<tr><td><input type="submit" value="submit" /></td></tr>
			</table>
		</form>	
	<?php	
		}
		if ($checkSubmit == 2)
		{
	?>
			<form method="post" action="get_meeting.php">
			<table cellpadding="0" cellspacing="0" class="apply4leave_table">
				<tr valign="top">
					<td>Employee Id</td>
					<td><input type="text" name="id" value="<?php echo $ID;?>" readonly=""/></td>
				</tr>
				<tr valign="top">
					<td>Employee Name</td>
					<td><input type="text" name="name" value="<?php echo $userName;?>" readonly=""/></td>
				</tr>
				<tr valign="top">
					<td>Event</td>
					<td><input type="text" name="event" /></td>
				</tr>
				<tr valign="top">
					<td>Date From</td>
					<td><select name="day"/>
												<option value="Day">Day</option><option value="1">1</option><option value="2">2</option>
												<option value="3">3</option><option value="4">4</option><option value="5">5</option>
												<option value="6">6</option><option value="7">7</option><option value="8">8</option>
												<option value="9">9</option><option value="10">10</option><option value="11">11</option>
												<option value="12">12</option><option value="13">13</option><option value="14">14</option>
												<option value="15">15</option><option value="16">16</option><option value="17">17</option>
												<option value="18">18</option><option value="19">19</option><option value="20">20</option>
												<option value="21">21</option><option value="22">22</option><option value="23">23</option>
												<option value="24">24</option><option value="25">25</option><option value="26">26</option>
												<option value="27">27</option><option value="28">28</option><option value="29">29</option>
												<option value="30">30</option><option value="31">31</option>
											</select>
											<select name="month"> 
												<option value="month1">Month</option><option value="1">January</option>
												<option value="2">February</option><option value="3">March</option><option value="4">April</option>
												<option value="5">May</option><option value="6">June</option><option value="7">July</option>
												<option value="8">august</option><option value="9">September</option>
												<option value="10">October</option><option value="11">November</option>
												<option value="12">December</option>
											</select>
											<select name="year">
												<option value="year">Year</option><option value="2012">2012</option><option value="2013">2013</option>
												<option value="2014">2014</option><option value="2015">2015</option><option value="2016">2016</option>
												<option value="2017">2017</option><option value="2018">2018</option><option value="2019">2019</option>
												<option value="2020">2020</option>
												</select></td>
				</tr>
				<tr valign="top">
					<td>Date To</td>
					<td><select name="day1"/>
												<option value="Day">Day</option><option value="1">1</option><option value="2">2</option>
												<option value="3">3</option><option value="4">4</option><option value="5">5</option>
												<option value="6">6</option><option value="7">7</option><option value="8">8</option>
												<option value="9">9</option><option value="10">10</option><option value="11">11</option>
												<option value="12">12</option><option value="13">13</option><option value="14">14</option>
												<option value="15">15</option><option value="16">16</option><option value="17">17</option>
												<option value="18">18</option><option value="19">19</option><option value="20">20</option>
												<option value="21">21</option><option value="22">22</option><option value="23">23</option>
												<option value="24">24</option><option value="25">25</option><option value="26">26</option>
												<option value="27">27</option><option value="28">28</option><option value="29">29</option>
												<option value="30">30</option><option value="31">31</option>
											</select>
											<select name="month1"> 
												<option value="month1">Month</option><option value="1">January</option>
												<option value="2">February</option><option value="3">March</option><option value="4">April</option>
												<option value="5">May</option><option value="6">June</option><option value="7">July</option>
												<option value="8">august</option><option value="9">September</option>
												<option value="10">October</option><option value="11">November</option>
												<option value="12">December</option>
											</select>
											<select name="year1">
												<option value="year">Year</option><option value="2012">2012</option><option value="2013">2013</option>
												<option value="2014">2014</option><option value="2015">2015</option><option value="2016">2016</option>
												<option value="2017">2017</option><option value="2018">2018</option><option value="2019">2019</option>
												<option value="2020">2020</option>
												</select></td>
				</tr>
				<tr valign="top">
					<td>Place</td>
					<td><input type="text"  name="place"/></td>
				</tr>
				<tr valign="top">
					<td>Supervisor</td>
					<td><input type="text" value= "<?php echo $supervisorName; ?>" name="supervisor" readonly=""/></td>
				</tr>
				<tr valign="top">
					<td>With Whom</td>
					<td><select name="whom">
							<option value="1">Rashid Khan</option><option value="51">Alamgir Hossain</option><option value="52">Rahat Hayat</option>
							<option value="54">Bahadur Imam</option><option value="55">Jakir Hossain</option><option value="56">T.I. Shohag</option>
							<option value="57">Mahin</option><option value="58">Md. Shakil</option><option value="60">Ruhul Amin</option>
							<option value="61">Raqibul Hasan</option><option value="64">A S M Nahid</option><option value="65">Waliur Rahman</option>
							<option value="66">Atukur Rahman</option><option value="67">Nur Arefin</option><option value="68">Subarna Sharika</option>
							<option value="69">Alamin Alamin</option><option value="70">Zaiuddin Babu</option><option value="71">Md. Jashim </option>
							<option value="72">Raiana Salmin</option><option value="73">Obaidur Rahman</option><option value="74">Nafiuzzaman</option>
							<option value="75">Md. Mehrab(Trino)</option><option value="76">Mamunur Rashid</option>
							<option value="77">Zilon Zilon</option><option value="62">Priyanka 	Sarker</option><option value="other">Others</option>
						</select></td>
				</tr>
				<tr>
					<td>Reason</td>
					<td><textarea name="reason" cols="19" rows="7s"></textarea></td>
				</tr>
				<tr><td><input type="hidden" name="isCheck" value="1"><input type="submit" value="submit" /></td></tr>
			</table>
		</form>
	<?php
		}
		if ($checkSubmit ==3)
		{
	?>
			<form method="post" action="work_night.php">
			<table cellpadding="0" cellspacing="0" class="apply4leave_table">
				<tr valign="top">
					<td>Employee Id</td>
					<td><input type="text" name="id" value="<?php echo $ID;?>" readonly="" /></td>
				</tr>
				<tr valign="top">
					<td>Employee Name</td>
					<td><input type="text" name="name" value="<?php echo $userName;?>" readonly="" /></td>
				</tr>
				<tr valign="top">
					<td>Sick From</td>
					<td><select name="day"/>
												<option value="Day">Day</option><option value="1">1</option><option value="2">2</option>
												<option value="3">3</option><option value="3">4</option><option value="3">5</option>
												<option value="3">6</option><option value="3">7</option><option value="3">8</option>
												<option value="3">9</option><option value="3">10</option><option value="3">11</option>
												<option value="3">12</option><option value="3">13</option><option value="3">14</option>
												<option value="3">15</option><option value="3">16</option><option value="3">17</option>
												<option value="3">18</option><option value="3">19</option><option value="3">20</option>
												<option value="3">21</option><option value="3">22</option><option value="3">23</option>
												<option value="3">24</option><option value="3">25</option><option value="3">26</option>
												<option value="3">27</option><option value="3">28</option><option value="3">29</option>
												<option value="3">30</option><option value="3">31</option>
											</select>
											<select name="month"> 
												<option value="month1">Month</option><option value="1">January</option>
												<option value="2">February</option><option value="3">March</option><option value="4">April</option>
												<option value="5">May</option><option value="6">June</option><option value="7">July</option>
												<option value="8">August</option><option value="9">September</option><option value="10">October</option>
												<option value="11">November</option><option value="12">December</option>
											</select>
											<select name="year">
												<option value="year">Year</option><option value="2012">2012</option><option value="2013">2013</option>
												<option value="2014">2014</option><option value="2015">2015</option><option value="2016">2016</option>
												<option value="2017">2017</option><option value="2018">2018</option><option value="2019">2019</option>
												<option value="2020">2020</option>
											</select><br><br>
						</td>
				</tr>
				<tr valign="top">
					<td>Sick To</td>
					<td><select name="day1"/>
												<option value="Day1">Day</option><option value="1">1</option><option value="2">2</option>
												<option value="3">3</option><option value="3">4</option><option value="3">5</option>
												<option value="3">6</option><option value="3">7</option><option value="3">8</option>
												<option value="3">9</option><option value="3">10</option><option value="3">11</option>
												<option value="3">12</option><option value="3">13</option><option value="3">14</option>
												<option value="3">15</option><option value="3">16</option><option value="3">17</option>
												<option value="3">18</option><option value="3">19</option><option value="3">20</option>
												<option value="3">21</option><option value="3">22</option><option value="3">23</option>
												<option value="3">24</option><option value="3">25</option><option value="3">26</option>
												<option value="3">27</option><option value="3">28</option><option value="3">29</option>
												<option value="3">30</option><option value="3">31</option>
											</select>
											<select name="month1"> 
												<option value="month1">Month</option><option value="1">January</option>
												<option value="2">February</option><option value="3">March</option><option value="4">April</option>
												<option value="5">May</option><option value="6">June</option><option value="7">July</option>
												<option value="8">August</option><option value="9">September</option><option value="10">October</option>
												<option value="11">November</option><option value="12">December</option>
											</select>
											<select name="year1">
												<option value="year1">Year</option><option value="2012">2012</option><option value="2013">2013</option>
												<option value="2014">2014</option><option value="2015">2015</option><option value="2016">2016</option>
												<option value="2017">2017</option><option value="2018">2018</option><option value="2019">2019</option>
												<option value="2020">2020</option>
												</select><br><br>
								</td>
				</tr>
				<tr valign="top">
					<td>Supervisor</td>
					<td><input type="text" name="supervisor" value="<?php echo $supervisorName?>" readonly="" /></td>
				</tr>
				<tr><td><input type="submit" value="submit" />
				<input type="hidden" name="isCheck" value="1">
				</td></tr>
			</table>
		</form>
	
	<?php
		}
	?>
</div>
</body>
</html>
<?php 
	$eid = $_POST['id'];
	$name = $_POST['name'];
	$sickFromDay = $_POST['day'];
	$sickFromMonth = $_POST['month'];
	$sickFromYear = $_POST['year'];
	$sickToDay = $_POST['day1'];
	$sickToMonth = $_POST['month1'];
	$sickToYear = $_POST['year1'];
	
	$isCheckSubmit = $_POST['isCheck'];
	
	$durationofSick = $sickFromDay."/".$sickFromMonth."/".$sickFromYear." - ".$sickToDay."/".$sickToMonth."/".$sickToYear;
	
	//Insert into medical_doc & notification Table
	if ($isCheckSubmit == 1)
	{		
		$insertSql = "INSERT INTO medical_doc (e_id,duration_of_sick,supervisor,is_delete,status)
			VALUES ('$eid','$durationofSick','$supervisor','0','2')";
		$insertSqlQuery = mysql_query($insertSql);
		
		$selectSql = "SELECT * FROM medical_doc WHERE e_id = $eid";
		$selectSqlQuery = mysql_query($selectSql);
		$selectSqlQueryResult = mysql_fetch_assoc($selectSqlQuery);
		
		$idofMedicalDoc = $selectSqlQueryResult['id'];
		
		$notificationSql = "INSERT INTO notification(reference_id,e_id,supervisor,Type,Reason,Status)
				VALUES ('$idofMedicalDoc','$eid','$supervisor','medical_doc','sick','2')";
		$notificationSqlResult = mysql_query($notificationSql);
	}
?>